<?php
/**
 * Created by PhpStorm.
 * User: MyPC
 * Date: 2016/7/22
 * Time: 9:25
 */

namespace Admin\Controller;
use Think\Controller;
class LoginController extends controller
{
    public function login()
    {
        $this->display();
    }
    public function dologin()
    {
        $condition=array('adminname'=>$_POST['adminname'],
            'password'=>md5(I('post.password')));


        $adminModel=M('admins');
        $admin=$adminModel->where($condition)->find();
        if($admin)
        {
            //合法用户
            session('admin',$admin);
            $this->redirect('Index/users');
        }
        else
        {
            $this->error('用户名或密码不正确！！');
        }

    }
    public function loginout()
    {
        session('admin',null);
        $this->redirect('login');
    }
}